package edu.gdkm.dao;

import edu.gdkm.pojo.Resume;
import org.apache.ibatis.annotations.*;
import java.util.List;

public interface ResumeDAO {
    /**
     * 新增简历
     * @param resume 简历对象
     * @return 是否成功
     */
    @Insert("INSERT INTO resume(user_id, resume_name, template_id, education_experience, work_experience, project_experience, skills, certificates, hobbies, language_ability, internship_experience, visibility, create_time, update_time) " +
            "VALUES(#{userId}, #{resumeName}, #{templateId}, #{educationExperience}, #{workExperience}, #{projectExperience}, #{skills}, #{certificates}, #{hobbies}, #{languageAbility}, #{internshipExperience}, #{visibility}, #{createTime}, #{updateTime})")
    boolean insert(Resume resume);
    
    /**
     * 根据ID删除简历
     * @param id 简历ID
     * @return 是否成功
     */
    @Delete("DELETE FROM resume WHERE id = #{id}")
    boolean deleteById(Long id);
    
    /**
     * 更新简历信息
     * @param resume 简历对象
     * @return 是否成功
     */
    @Update("UPDATE resume SET user_id = #{userId}, resume_name = #{resumeName}, template_id = #{templateId}, education_experience = #{educationExperience}, work_experience = #{workExperience}, project_experience = #{projectExperience}, skills = #{skills}, certificates = #{certificates}, hobbies = #{hobbies}, language_ability = #{languageAbility}, internship_experience = #{internshipExperience}, visibility = #{visibility}, update_time = #{updateTime} WHERE id = #{id}")
    boolean update(Resume resume);
    
    /**
     * 根据ID查询简历
     * @param id 简历ID
     * @return 简历对象
     */
    @Select("SELECT * FROM resume WHERE id = #{id}")
    Resume selectById(Long id);
    
    /**
     * 查询所有简历
     * @return 简历列表
     */
    @Select("SELECT * FROM resume")
    List<Resume> selectAll();
    
    /**
     * 根据用户ID查询简历列表
     * @param userId 用户ID
     * @return 简历列表
     */
    @Select("SELECT * FROM resume WHERE user_id = #{userId}")
    List<Resume> selectByUserId(Long userId);
    
    /**
     * 根据简历名称查询简历
     * @param resumeName 简历名称
     * @return 简历列表
     */
    @Select("SELECT * FROM resume WHERE resume_name LIKE CONCAT('%', #{resumeName}, '%')")
    List<Resume> selectByResumeName(String resumeName);
    
    /**
     * 查询公开的简历列表
     * @return 公开简历列表
     */
    @Select("SELECT * FROM resume WHERE visibility = 1")
    List<Resume> selectPublicResumes();
}
